/**
 * Copyright 2009. Felix Dorner.
 * This code is licensed under the Eclipse Public License v1.0
 * http://www.eclipse.org/org/documents/epl-v10.html
 *
 * $Id$
 */
package com.objectcarpentry.kaylee.impl;

import com.objectcarpentry.kaylee.*;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;

import com.objectcarpentry.kaylee.KayleeFactory;
import com.objectcarpentry.kaylee.KayleePackage;
import com.objectcarpentry.kaylee.Library;
import com.objectcarpentry.kaylee.Playlist;
import com.objectcarpentry.kaylee.PlaylistEntry;
import com.objectcarpentry.kaylee.State;
import com.objectcarpentry.kaylee.Track;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class KayleeFactoryImpl extends EFactoryImpl implements KayleeFactory {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final String copyright = "Copyright 2009. Felix Dorner.\nThis code is licensed under the Eclipse Public License v1.0\nhttp://www.eclipse.org/org/documents/epl-v10.html";

	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static KayleeFactory init() {
		try {
			KayleeFactory theKayleeFactory = (KayleeFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.objectcarpentry.com/kaylee/xmlns/1.0"); 
			if (theKayleeFactory != null) {
				return theKayleeFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new KayleeFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public KayleeFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case KayleePackage.TRACK: return createTrack();
			case KayleePackage.LIBRARY: return createLibrary();
			case KayleePackage.PLAYLIST: return createPlaylist();
			case KayleePackage.PLAYLIST_ENTRY: return createPlaylistEntry();
			case KayleePackage.FILTERED_PLAYLIST: return createFilteredPlaylist();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case KayleePackage.PLAYABLE_STATE:
				return createPlayableStateFromString(eDataType, initialValue);
			case KayleePackage.URI:
				return createURIFromString(eDataType, initialValue);
			case KayleePackage.IPLAYLIST_CONTROLLER:
				return createIPlaylistControllerFromString(eDataType, initialValue);
			case KayleePackage.IPLAYABLE_FILTER:
				return createIPlayableFilterFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case KayleePackage.PLAYABLE_STATE:
				return convertPlayableStateToString(eDataType, instanceValue);
			case KayleePackage.URI:
				return convertURIToString(eDataType, instanceValue);
			case KayleePackage.IPLAYLIST_CONTROLLER:
				return convertIPlaylistControllerToString(eDataType, instanceValue);
			case KayleePackage.IPLAYABLE_FILTER:
				return convertIPlayableFilterToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Track createTrack() {
		TrackImpl track = new TrackImpl();
		return track;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Library createLibrary() {
		LibraryImpl library = new LibraryImpl();
		return library;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Playlist createPlaylist() {
		PlaylistImpl playlist = new PlaylistImpl();
		return playlist;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PlaylistEntry createPlaylistEntry() {
		PlaylistEntryImpl playlistEntry = new PlaylistEntryImpl();
		return playlistEntry;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FilteredPlaylist createFilteredPlaylist() {
		FilteredPlaylistImpl filteredPlaylist = new FilteredPlaylistImpl();
		return filteredPlaylist;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PlayableState createPlayableStateFromString(EDataType eDataType, String initialValue) {
		PlayableState result = PlayableState.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertPlayableStateToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public URI createURIFromString(EDataType eDataType, String initialValue) {
		return URI.createURI(initialValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertURIToString(EDataType eDataType, Object instanceValue) {
		return super.convertToString(eDataType, instanceValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IPlaylistController<?> createIPlaylistControllerFromString(EDataType eDataType, String initialValue) {
		return (IPlaylistController<?>)super.createFromString(initialValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertIPlaylistControllerToString(EDataType eDataType, Object instanceValue) {
		return super.convertToString(instanceValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IPlayableFilter createIPlayableFilterFromString(EDataType eDataType, String initialValue) {
		return (IPlayableFilter)super.createFromString(eDataType, initialValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertIPlayableFilterToString(EDataType eDataType, Object instanceValue) {
		return super.convertToString(eDataType, instanceValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public KayleePackage getKayleePackage() {
		return (KayleePackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static KayleePackage getPackage() {
		return KayleePackage.eINSTANCE;
	}

} //KayleeFactoryImpl
